import {Controller, Get, UseInterceptors} from '@nestjs/common';
import {LoggerInterceptor, LoggerInterceptor2,LoggerInterceptor3,LoggerInterceptor4} from './interceptors/logger.interceptor'

@Controller('app')
@UseInterceptors(LoggerInterceptor3)         // 后执行----先执行after
@UseInterceptors(LoggerInterceptor4)        //先执行----后执行after           洋葱圈
export class AppController {
    @Get('index')
    @UseInterceptors(LoggerInterceptor)         // 后执行----先执行after
    @UseInterceptors(LoggerInterceptor2)        //先执行----后执行after           洋葱圈
    async getIndex() {
        console.log('app.index...')
        for (let k = 0; k < 3; k++) {
            console.log(`for(let k=${k};k<3;k++)`)
        }
        return 'app.index'
    }
}
/*

LoggerInterceptor2 Before...
Before...
app.index...
for(let k=0;k<3;k++)
for(let k=1;k<3;k++)
for(let k=2;k<3;k++)
app.index
After... 1ms
app.index
LoggerInterceptor2 After... 2ms

* */
